﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Product;

namespace Broker.Mgr.ViewModel
{
    public static class ProductViewUtil
    {

        public static IList<DisplayRateRow> GetDisplayRateRows(IProduct product)
        {
            IList<IRateRow> rows = product.RateRows;

            IList<DisplayRateRow> dRows = new List<DisplayRateRow>();

            var query = from r in product.RateRows group r by new { r.Key1, r.Key2 };

            foreach (var g in query)
            {
                IRateRow[] tmp = g.ToArray<IRateRow>();

                DisplayRateRow dRow = new DisplayRateRow(tmp);
                dRows.Add(dRow);
            }

            return dRows;
        }
    }
}
